home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / watcom / llcomm13 / ll_comm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-26  |  4.9 KB  |  167 lines

  1. /*
  2. ** LL_COMM (R) Asynchronous Communication Routines
  3. ** Copyright (C) 1994 by James P. Ketrenos
  4. **
  5. ** VERSION    :    1.2
  6. ** DATE     :    7-4-94
  7. ** CODED BY :   James P. Ketrenos [ketrenoj@cs.pdx.edu]
  8. **      aka :   Lord Logics (for those who care)
  9. **
  10. ** Special thanks to all of the contributors to the Serial.FAQ
  11. **
  12. *
  13. *    NOTE:  As of this release, these routines only allow for ONE port to be
  14. *    opened at a time.  Hopefully, if all goes well, the next version will
  15. *    allow for up to 32 different ports to be opened.  I have set up these
  16. *    routines to be compatible with the future format, so using the next
  17. *    version shouldn't require much, if any, change to working code.
  18. *
  19. *    Also, you probably have noticed that the assembly listings for this code
  20. *    have not been included.  If you are interested in the assembly code,
  21. *    please read the file LL_COMM.NFO, as it explains why it is not here, and
  22. *    where/how you can acquire it.
  23. *
  24. **
  25. */
  26.  
  27. #ifndef _LL_COMM_H_
  28. #define _LL_COMM_H_
  29. #ifdef    __cplusplus
  30. #define CEXT    extern "C"
  31. #else
  32. #define CEXT    extern
  33. #endif
  34.  
  35. typedef int     COMM;
  36. typedef char    *PACKET;
  37.  
  38. #ifndef TRUE
  39. #define TRUE    1
  40. #define FALSE    0
  41. #endif
  42.  
  43. /* Initialization Routines    ****/
  44. CEXT    COMM    ioOpenPort(int Base, int IRQ);
  45. CEXT    int     ioClosePort(COMM Port);
  46.  
  47. /* Buffer Routines            ****/
  48. CEXT    void    ioClearWrite(COMM);
  49. CEXT    void    ioClearRead(COMM);
  50. CEXT    int     ioReadStatus(COMM);
  51. CEXT    int     ioWriteStatus(COMM);
  52.  
  53. /* I/O Routines             ****/
  54. CEXT    char    ioReadByte(COMM);
  55. CEXT    int     ioWriteByte(COMM, char);
  56. CEXT    int     ioReadPacket(COMM, PACKET);
  57. CEXT    int     ioWritePacket(COMM, PACKET);
  58.  
  59. /* Mode Routines            ****/
  60. CEXT    int     ioGetMode(COMM);
  61. CEXT    int     ioSetMode(COMM, int);
  62.  
  63. /* Port Setup Routines        ****/
  64. CEXT    int     ioGetBaud(COMM);
  65. CEXT    void    ioSetBaud(COMM, int);
  66. CEXT    int     ioGetHandShake(COMM);
  67. CEXT    void    ioSetHandShake(COMM, int);
  68. CEXT    int     ioGetStatus(COMM);
  69. CEXT    int     ioGetControl(COMM);
  70. CEXT    void    ioSetControl(COMM, int);
  71. CEXT    int     ioGetFIFO(COMM);
  72. CEXT    int     ioSetFIFO(COMM, int);
  73.  
  74. /*
  75. ** ISR I/O Modes
  76. */
  77. /********************************........xx..    */
  78. #define BYTE_MODE        0x00    /* 00000000b    */
  79. #define PACKET_MODE     0x01    /* 00000001b    */
  80. #define VARIABLE_MODE    0x02    /* 00000010b    */
  81.  
  82. /*
  83. ** Line Control Register
  84. */
  85. /********************************........xx..    */
  86. #define CLEAR_BITS        0xFC    /* 11111100b    */
  87. #define BITS_5            0x00    /* 00000000b    */
  88. #define BITS_6            0x01    /* 00000001b    */
  89. #define BITS_7            0x02    /* 00000010b    */
  90. #define BITS_8            0x03    /* 00000011b    */
  91. /********************************.......x...    */
  92. #define CLEAR_STOP        0xFB    /* 11111011b    */
  93. #define STOP_1            0x00    /* 00000000b    */
  94. #define STOP_2            0x04    /* 00000100b (Doesn't work w/ BITS_5) */
  95. /*********************************...xxx....    */
  96. #define CLEAR_PARITY    0xE7    /* 11000111b    */
  97. #define NO_PARITY        0x00    /* 00000000b    */
  98. #define ODD_PARITY        0x08    /* 00001000b    */
  99. #define EVEN_PARITY     0x18    /* 00011000b    */
  100. #define MARK_PARITY     0x28    /* 00101000b    */
  101. #define SPACE_PARITY    0x38    /* 00111000b    */
  102. /********************************...x.......    */
  103. #define CLEAR_MODE        0xBF    /* 10111111b    */
  104. #define NORMAL            0x00    /* 00000000b    */
  105. #define BREAK            0x40    /* 01000000b    */
  106.  
  107. /*
  108. ** HandShaking
  109. */
  110. #define    DTR                0x01    // 00000001b
  111. #define    RTS                0x02    // 00000010b
  112. #define LOOPBACK        0x10    // 00010000b
  113.  
  114. /*
  115. ** Modem/Line Status Register
  116. */
  117. #define    D_CTS            0x0100    // 00000001 00000000b
  118. #define    D_DSR            0x0200    // 00000010 00000000b
  119. #define    D_RI            0x0400    // 00000100 00000000b
  120. #define    D_DCD            0x0800    // 00001000 00000000b
  121. #define    CTS                0x1000    // 00010000 00000000b
  122. #define    DSR                0x2000    // 00100000 00000000b
  123. #define    RI                0x4000    // 01000000 00000000b
  124. #define    DCD                0x8000    // 10000000 00000000b
  125. #define RBF             0x0001    // 00000000 00000001b
  126. #define OVR_ERROR        0x0002    // 00000000 00000010b
  127. #define    PAR_ERROR        0x0004    // 00000000 00000100b
  128. #define FRM_ERROR        0x0008    // 00000000 00001000b
  129. #define    BRK_ERROR        0x0010    // 00000000 00010000b
  130. #define    THREMPTY        0x0020    // 00000000 00100000b
  131. #define TEMPTY            0x0040    // 00000000 01000000b
  132. #define FFO_ERROR        0x0080    // 00000000 10000000b
  133.  
  134.  
  135. /* WATCOM Specific Parameter Passing Setup    */
  136. #pragma aux  ioOpenPort     parm    [EDX] [ECX]
  137. #pragma aux  ioClosePort    parm    [EAX]
  138.  
  139. #pragma aux  ioClearRead    parm    [EAX]
  140. #pragma aux  ioClearWrite    parm    [EAX]
  141. #pragma aux  ioReadStatus    parm    [EAX]
  142. #pragma aux  ioWriteStatus    parm    [EAX]
  143.  
  144. #pragma aux  ioReadByte     parm    [EAX]
  145. #pragma aux  ioWriteByte    parm    [EAX] [ECX]
  146. #pragma aux  ioReadPacket    parm    [EAX]
  147. #pragma aux  ioWritePacket    parm    [EAX] [ESI]
  148.  
  149. #pragma aux  ioGetBaud        parm    [EAX]
  150. #pragma aux  ioSetBaud        parm    [EAX] [EBX]
  151.  
  152. #pragma aux  ioGetHandShake parm    [EAX]
  153. #pragma aux  ioSetHandShake parm    [ECX] [EAX]
  154.  
  155. #pragma aux  ioGetStatus    parm    [EAX]
  156.  
  157. #pragma aux  ioGetControl    parm    [EAX]
  158. #pragma aux  ioSetControl    parm    [ECX] [EAX]
  159.  
  160. #pragma aux  ioGetFIFO        parm    [EAX]
  161. #pragma aux  ioSetFIFO        parm    [EAX] [ECX]
  162.  
  163. #pragma aux  ioGetMode        parm    [EAX]
  164. #pragma aux  ioSetMode        parm    [EAX] [ECX]
  165.  
  166. #endif
  167.